<!DOCTYPE html>
<html lang="en" xmlns:C="http://java.sun.com/jsp/jstl/core" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>仓储宝 - 产地列表</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        .actions-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .search-container {
            display: flex;
            align-items: center;

        }

        .actions-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .search-form {
            display: flex;
            align-items: center;
        }

        .search-input {
            height: 30px; /* Adjust the height as needed */
            margin-right: 5px;
        }

    </style>
</head>

<body class="gray-bg">
    <div class="container-fluid">
        <div class="ibox-title actions-container">
            <button id="addProductButton" type="button" class="btn btn-primary btn-sm">
                <a href="/#" style="color: white;">增加产地</a>
            </button>
            <form action="/#" class="search-form">
                <div class="search-container">
                    <input type="text" name="search" placeholder="输入搜索关键词" class="search-input">
                    <button class="btn btn-primary" type="submit">搜索</button>
                </div>
            </form>
        </div>

    <div class="table-responsive">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>序号</th>
                <th>产地名</th>
                <th>介绍</th>
                <th>是否启用</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="place:${placeList}">
                <td>[(${place.place_id})]</td>
                <td>[(${place.place_name})]</td>
                <td>[(${place.introduce})]</td>
                <td>[(${place.is_delete})]</td>
                <td>
                    <button class="btn btn-primary">
                        <a th:href="@{/deletePlace(place_id=${place.place_id})}"
                           onclick="deletePlace('${place.place_id}')" style="color: white;">删除</a>
                    </button>
                    <button class="btn btn-primary">
                        <a th:href="@{/toUpdatePlace(place_id=${place.place_id})}"
                           style="color: white;">修改</a>
                    </button>


                </td>
            </tr>
            </tbody>
        </table>
    </div>
    </div>
</div>
<script>
    function deletePlace(place_id) {
        var flag = confirm("确定删除？");
        if (flag) {
            location.href = "deletePlace?place_id=" + place_id;
        }
    }

    //搜索
    $(document).ready(function() {
        $('#searchButton').click(function() {
            var keyword = $('#searchInput').val().trim();

            if (keyword !== '') {
                $.post('/selectProduct', { keyword: keyword }, function(data) {
                    var highlightedData = highlightKeyword(data, keyword);
                    $('#listProduct').html(highlightedData);
                });
            } else {
                alert('请输入搜索关键词');
            }
        });

        //显示关键词的函数
        function highlightKeyword(text, keyword) {
            var regex = new RegExp('(' + keyword + ')', 'gi');
            return text.replace(regex, '<span class="search-result">$1</span>');
        }
    });
</script>



<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.7"></script>



<!-- Peity -->
<script src="js/plugins/peity/jquery.peity.min.js"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>


<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>

<!-- Peity -->
<script src="js/demo/peity-demo.js"></script>




<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<!--统计代码，可删除-->

</body>

</html>